import { getDB } from "../../utils/db/mysql";
export default defineEventHandler(async (req) => {
  // console.log("获取", req.node.req.body);
  let path = req.node.req.body;
  let con = getDB();
  if (path) {
    let result = await con.execute(`select * from  news where path = ${path}`);
    //释放连接
    await con.end();
    if (result[0].length != 0) {
      return {
        code: 2000,
        data: result[0],
      };
    } else {
      return {
        code: 4004,
        data: "没有数据",
      };
    }
  } else {
    return {
      code: 4003,
      message: "没能获取path",
    };
  }
});
